<%@page import="org.hibernate.validator.constraints.SafeHtml.Tag"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目产品详情</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
  <div>
<div id="pageInTab" class="pageInTab">
   	 	<form id="basePrdForm1">
     	<div tabid="tabA" title="产品基本信息" lselected="true">
       			<div class="fieldset1 tabel_col clearFix">
       			   <div class="caption">
                                <span class="title">主车配置</span>
                    </div>
               		 <div style="display: none">
               		 	<input name="mfrId" id="mfrId" type="hidden"  value=""  class="ui-textbox"  disabled="disabled">
               		 	<input name="brCd" id="brCd" type="text"  value=""  class="ui-textbox"  disabled="disabled">
               		 	<input name="prdbscInfoId" id="prdbscInfoId"  type="hidden"  value=""   class="ui-textbox"  disabled="disabled">
               		 	<input name="carId" id="carId"  type="hidden"  value=""   class="ui-textbox"  disabled="disabled">
               		 	<input name="tkId" id="tkId"  type="hidden"  value=""   class="ui-textbox"  disabled="disabled">
               		 	<input name="prdId" id="prdId"  type="hidden"  value="${prjPrd.prdId}"   class="ui-textbox"  disabled="disabled">
               		 	<input name="detailId" id="detailId"  type="hidden"  value=""   class="ui-textbox"  disabled="disabled">
               		 	 <input name="basePrdId" id="basePrdId"  type="hidden"  value=""   class="ui-textbox"  disabled="disabled">
               		 	 <input name="styleId" id="styleId"  type="hidden"  value=""   class="ui-textbox"  disabled="disabled">

               		 </div>
                   	<div class="fieldBox col_33" >
	                        	<div class="label">产品名称1</div>
				                <div class="field">
				                	<input name="prdNm" id="prdNm" type="text"  value="${prjPrd.prdNm}"  class="ui-textbox"  readonly="readonly">
				                </div>
				           </div>
				              <div class="fieldBox col_33" >
	                        	<div class="label">产品品牌</div>
				                <div class="field">
				                	<input type="text"   name="brCd"  value="${prjPrd.brCd}"  class="ui-textbox"  readonly="readonly">
				                	<%-- <input name="brCd"  id="brCd"  type="text"  value="${prd.prjPrdBscInfo.brCd}"  class="ui-textbox"  readonly="readonly"> --%>
				                </div>
				           </div>
				               <div class="fieldBox col_66" >
	                        	<div class="label">产品型号</div>
				                <div class="field">
				                	<input name="prdMdl" id="prdMdl" type="text"  value="${dtlVO.prdMdl}"  class="ui-textbox"  readonly="readonly" >
				                	<span id="prdMdlChoose" class="sq-button sq-button-hasicon" onclick="choosePrd();"><i class="sqBtnIco_1"></i>更改</span>
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">排量(L)</div>
				                <div class="field">
				                	<input name="outVol" id="outVol" type="text"  value="${prd.outVol}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				             <div class="fieldBox col_33" >
	                        	<div class="label">发动机型号</div>
				                <div class="field">
				                	<input name="engMdl"  id="engMdl"  type="text"  value="${prd.engMdl}"  onblur="checkPrdMdlValue();" class="ui-textbox"  readonly="readonly">
				                </div>
				           </div> 
				           <div class="fieldBox col_33" >
	                        	<div class="label">国别代码</div>
				                <div class="field">
				                	<input name="prdCyCd" id="prdCyCd" type="text"  value="${prd.prdCyCd}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">座位</div>
				                <div class="field">
				                	<input name="seatQtyCd" id="seatQtyCd" type="text"  value="${prd.seatQtyCd}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">驱动形式</div>
				                <div class="field">
				                	<input name="drvTypCd" id="drvTypCd" type="text"  value="${prd.drvTypCd}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">车身结构</div>
				                <div class="field">
				                	<input name="carStrcCd" id="carStrcCd" type="text"  value="${prd.carStrcCd}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">车身颜色</div>
				                <div class="field">
				                	<input name="carCl" id="carCl" type="text"  value="${prd.carCl}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">最高车速</div>
				                <div class="field">
				                	<input name="maxSpd" id="maxSpd" type="text"  value="${prd.maxSpd}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">最大马力</div>
				                <div class="field">
				                	<input name="maxHp" id="maxHp" type="text"  value="${prd.maxHp}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           <div class="fieldBox col_33" >
	                        	<div class="label">车门数</div>
				                <div class="field">
				                	<input name="doorNum" id="doorNum" type="text"  value="${prd.doorNum}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				            <div class="fieldBox col_100" >
	                        	<div class="label">供应商名称</div>
				                <div class="field">
				                	<input name="splNm" id="splNm" type="text"  value="${prjPrd.splNm}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div> 
				             <div class="fieldBox col_100" >
	                        	<div class="label">厂商名称</div>
				                <div class="field">
				                	<input name="mfrNm" id="mfrNm" type="text"  value="${prjPrd.mfrNm}"  class="ui-textbox" readonly="readonly">
				                </div>
				           </div>
				           
				                 
				         </div> 
                </div>
  
	 
	 <div id="btnsBox" class="btnsBox">
			<span id="saveBtn" class="sq-button sq-button-round" onclick="savePrjBscInfo()"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
           <span id="cancelBtn" class="sq-button sq-button-round" onclick="cancelBtn()"><!-- <i class="sqBtnIco_14"></i> -->取消</span>
	 </div> 
	  </form>
	  <div id="prddetail" style="display: none">
		  <div class="sqCaption-normal TC">
		        <div class="tit">
		            产品明细信息
		        </div>
		    </div>
		    	<form id="prjPrdDtlForm">
		    		<div class="fieldset1 tabel_col clearFix">
		    		<div class="fieldBox col_100">
				                    <div class="label">挂靠公司</div>
				                    <div class="field">
				                     <span> 
				                    <input name="lnkCompNm" id="lnkCompNm"  type="text"  class="ui-textbox"   value="${dtlVO.lnkCompNm}" >
				                     </span>
				                     <input name="lnkCompId" id="lnkCompId" type="hidden"  value="${dtlVO.lnkCompId}" >
				                     	<span id="chooseLnkComp" class="sq-button sq-button-hasicon" onclick="choosePrjLnkComp();"><i class="sqBtnIco_1"></i>更改</span>
				                    </div>
		               		 </div>
		    	      <div class="fieldBox col_50">
				                    <div class="label">GPS卡号1</div>
				                    <div class="field">
				                    <%--  <span id="gpsCardNo">${vehInfo.prjPrdDtl.gpsCardNo}</span> --%>
				                     	<input name="gpsCardNo"  id="gpsCardNo" type="text" class="ui-textbox"  value="${dtlVO.gpsCardNo}" >
				                    </div>
		               		 </div>
		               		 
		               		   <div class="fieldBox col_50">
				                    <div class="label">GPS卡号2</div>
				                    <div class="field">
				                    <%--  <span id="gpsCardNo2">${vehInfo.prjPrdDtl.gpsCardNo2}</span> --%>
				                	<input name="gpsCardNo2"  id="gpsCardNo2" type="text" class="ui-textbox"  value="${dtlVO.gpsCardNo2}" >
				                    </div>
		               		 </div>
		               		 </div>
		               		 <div id="btnsBox" class="btnsBox">
						<span id="moreBtn" class="sq-button sq-button-round"
							onclick="moreGps();" style="display:none">更多GPS卡号
						</span>
					</div>
					<div class="fieldset1 tabel_col clearFix" id="moreGps">
							<span id="addGps" class="sq-button sq-button-round" onclick="addGps();" >新增GPS卡号</span>
							<c:forEach items="${moreGpsList}" var="item">
							<div class="fieldBox col_100">
								<div class="label" style="width:13.5%;padding-left:2%">
								GPS卡号</div>
								<div class="field" style="padding-left:15%;width:58%">
										<input type="text" id="gpsCardNoMore" name="gpsCardNoMore"
										value="${item.gpsCardNo}" class="moreGps">
								</div>
								<span id="deleteButton" class="sq-button-hasicon onlyicon deleteButton" onclick="deleteGps(this);" ><i class="sqBtnIco_7"></i></span>
							</div>
							</c:forEach>
					</div>
		               		 <div id="btnsBox" class="btnsBox">
								<span id="savePrjPrdDtlBtn" class="sq-button sq-button-round" onclick="savePrjPrdDtlInfo()"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
           						<span id="cancelBtn1" class="sq-button sq-button-round" onclick="cancelBtn()"><!-- <i class="sqBtnIco_14"></i> -->取消</span>
							 </div>
		    	</form>
		    	</div>
	</div>
</div>
</div>


<script type="text/javascript">
var dtlId = '${dtlId}';
var tkFlag = '${tkFlag}';
var detailFlag = '${detailFlag}';
var prdTypCd = '${prdTypCd}';//产品分类
var ywParam = '${ywParam}';
var hasCarFlag = '${hasCarFlag}';
$(function () {
	
	if(ywParam=="1"){
		$("#prddetail").hide();
	}
	
	 var basePrdForm1 = liger.get("basePrdForm1");
		var form = $("#basePrdForm1").ligerForm({
			validate: true
	    });
		
		 var prjPrdDtlForm = liger.get("prjPrdDtlForm");
			var prdForm = $("#prjPrdDtlForm").ligerForm({
				validate: true
		    });
		/* if(liger.get("brTypCd")&&liger.get("brTypCd")!="undefined"){
			liger.get("brTypCd").setDisabled(true);
		}
		
		if(liger.get("prdClsCd")&&liger.get("prdClsCd")!="undefined"){
			liger.get("prdClsCd").setDisabled(true);
		}
		
		if(liger.get("buyWayCd")&&liger.get("buyWayCd")!="undefined"){
			liger.get("buyWayCd").setDisabled(true);
		}
		if(liger.get("drvTyp")&&liger.get("drvTyp")!="undefined"){
			liger.get("drvTyp").setDisabled(true);
		}
		if(liger.get("hp")&&liger.get("hp")!="undefined"){
			liger.get("hp").setDisabled(true);
		}
		if(liger.get("mWhlSpec")&&liger.get("mWhlSpec")!="undefined"){
			liger.get("mWhlSpec").setDisabled(true);
		}
		if(liger.get("matQatCd")&&liger.get("matQatCd")!="undefined"){
			liger.get("matQatCd").setDisabled(true);
		}
		if(liger.get("liftWayCd")&&liger.get("liftWayCd")!="undefined"){
			liger.get("liftWayCd").setDisabled(true);
		}
		if(liger.get("trlWhlSpec")&&liger.get("trlWhlSpec")!="undefined"){
			liger.get("trlWhlSpec").setDisabled(true);
		}
		
		if($("#othInfo")&&$("#othInfo")!="undefined"){
			$("#othInfo").setDisabled_ligerTextarea(true);
		} */
		if(detailFlag=="true"){
			if(liger.get("prdMdl")&&liger.get("trlWhlSpec")!="undefined"){
				liger.get("prdMdl").setDisabled(true);
			}
			if(liger.get("engMdl")&&liger.get("trlWhlSpec")!="undefined"){
				liger.get("engMdl").setDisabled(true);
			}
			
			if(liger.get("gpsCardNo")&&liger.get("gpsCardNo")!="undefined"){
				liger.get("gpsCardNo").setDisabled(true);
			}
			if(liger.get("gpsCardNo2")&&liger.get("gpsCardNo2")!="undefined"){
				liger.get("gpsCardNo2").setDisabled(true);
			}
			if(liger.get("lnkCompNm")&&liger.get("lnkCompNm")!="undefined"){
				liger.get("lnkCompNm").setDisabled(true);
			}
			$("#prdMdlChoose").hide();
			$("#chooseLnkComp").hide();
			$("#saveBtn").hide();
			$("#savePrjPrdDtlBtn").hide();
			$("#cancelBtn").hide();
			$("#cancelBtn1").hide();
			$("span[id='deleteButton']").each(function(){
				$(this).hide();
			});
			$("input[id='gpsCardNoMore']").each(function(){
				$(this).attr("readonly","true");
			});
		}
})

  function moreGps(){
		if(isShow==0){
			$("#moreBtn").html("隐藏");
			$("#moreGps").show();
			isShow = 1;
		}else{
			$("#moreBtn").html("更多GPS卡号");
			$("#moreGps").hide();
			isShow = 0;
		}
	}

	function addGps(){
	/* gpscount++;
	$("#moreGps").append('<div class="fieldBox col_100"><div class="label" style="width:13.5%;padding-left:2%;float:left">GPS卡号</div><div style="padding-left:15%;width:41.5%;float:left"><input type="text" id="gpsCardNo'+gpscount+'" name="gpsCardNo'+gpscount+'" value="" class="moreGps"></div><span class="sq-button-hasicon onlyicon deleteButton" onclick="deleteGps();" style="margin-left:1.5%" ><i class="sqBtnIco_7"></i></span></div>'); */
		$("#moreGps").append('<div class="fieldBox col_100"><div class="label" style="width:13.5%;padding-left:2%;float:left">GPS卡号</div><div style="padding-left:15%;width:41.5%;float:left"><input type="text" id="gpsCardNoMore" name="gpsCardNoMore" value="" class="moreGps"></div><span id="deleteButton" class="sq-button-hasicon onlyicon deleteButton" onclick="deleteGps(this);" style="margin-left:1.5%" ><i class="sqBtnIco_7"></i></span></div>')
	}

	function deleteGps(owner){
		$(owner).parent().remove();
	}
  //取消
	function cancelBtn(){
		  var TAB=top.mainApp.parentTab;
          var currentTabid=TAB.getSelectedTabItemID();
		 top.tab.removeTabItem(currentTabid);
	}
  
	//保存项目基础信息
	function savePrjBscInfo(){
        var ligerForm = liger.get("basePrdForm1");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var params = {};
        params.engMdl = $("#engMdl").val();
        params.prdMdl =  $("#prdMdl").val();
        params.tkFlag = tkFlag;
        params.hasCarFlag = hasCarFlag;
        params.dtlId = dtlId;
        params.detailId = $("#detailId").val();
        params.prdId=$("#basePrdId").val();
        params.styleId=$("#styleId").val();
        var url = '<%=path%>/project/prjprddtl/modifyPrdDtlPrdInfo.do';
        var wait_dialog;
        $.ajax({
    		type: 'post',
    		dataType:'json',
    		data:params,
    		url: url,
    		beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
    		success:function(msg){
    				 wait_dialog.close();
    			 if(msg.success == 1){
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
    					var TAB=top.mainApp.parentTab;
			            var currentTabid=TAB.getSelectedTabItemID();
			            var currFrameElement=top.$("#"+currentTabid).get(0);
						 var callback=currFrameElement.W2W.callback;
		          	  		callback();
		          	 	 top.tab.removeTabItem(currentTabid); 
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }
    		}
    	});
	}
	//保存挂靠公司、gps信息
	function savePrjPrdDtlInfo(){
        var ligerForm = liger.get("prjPrdDtlForm");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var params = {};
        params.gpsCardNo = $("#gpsCardNo").val();
        params.gpsCardNo2 =  $("#gpsCardNo2").val();
        params.id = dtlId;
        params.lnkCompNm = $("#lnkCompNm").val();
        params.lnkCompId=$("#lnkCompId").val();
        var moreGpsStr = "";
        $("#moreGps input").each(function(){
        	if($(this).val()!=""){
        		moreGpsStr +=$(this).val()+",";
        	}
		});
        params.moreGps = moreGpsStr;
        var url = '<%=path%>/project/prjprddtl/modify.do';
        var wait_dialog;
        $.ajax({
    		type: 'post',
    		dataType:'json',
    		data:params,
    		url: url,
    		beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
    		success:function(msg){
    				 wait_dialog.close();
    			 if(msg.success == 1){
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
    					var TAB=top.mainApp.parentTab;
			            var currentTabid=TAB.getSelectedTabItemID();
			            var currFrameElement=top.$("#"+currentTabid).get(0);
						 var callback=currFrameElement.W2W.callback;
		          	  		callback();
		          	 	 top.tab.removeTabItem(currentTabid); 
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }
    		}
    	});
	}
    //检查产品型号是否有值
	function checkPrdMdlValue(){
		var prdMdl = $("#prdMdl").val();
		if(!prdMdl){
			 top.$.ligerDialog.SQalert({content: "请先选择产品明细信息！",SQ_type: "info"});
		}
    	
	}
	//重新更换产品型号
    function choosePrd(){
    	var prdId = $("#prdId").val();
        $.ligerDialog.open({ title: '产品详细信息',height: 400,width: 900, url: '<%=path%>/project/prjprddtl/toChoosePrdListPage.do?prdId='+prdId+'&&prdTypCd='+prdTypCd, isResize: true });
    }
	
	function choosePrjLnkComp(){
        $.ligerDialog.open({  title: '更改产品挂靠公司',height: 500,width: 850, url:'<%=path%>/project/prjprdvehinfo/toChooseLnkCompPage.do'});
	}
</script>
<div class="ClearLine"></div>
</body>
</html>
